#pragma once
#include "HashTable.h"
namespace wnf
{
	template<class K,class V,class Hash = GetKeyForHash<K>>
	class unordered_map
	{
		struct GetMapKey
		{
			const K& operator()(const pair<K, V>& data)
			{
				return data.first;
			}
		};
	public:
		typedef typename HashTable<K, pair<const K, V>, Hash, GetMapKey>::Iterator iterator;
		typedef typename HashTable<K, pair<const K, V>, Hash, GetMapKey>::ConstIterator const_iterator;
		
		iterator begin()
		{
			return _ht.begin();
		}
		iterator begin() const
		{
			return _ht.begin();
		}
		iterator end()
		{
			return _ht.end();
		}
		iterator end() const
		{
			return _ht.end();
		}
		pair<iterator,bool> insert(const pair<const K,V>& data)
		{
			return _ht.insert(data);
		}

		bool erase(const K& key)
		{
			return _ht.erase(key);
		}

		iterator find(const K& key)
		{
			return _ht.find(key);
		}

		V& operator[](const K& key)
		{
			auto ret = insert({ key,V() });
			return ret.first->second;
		}
	private:
		HashTable<K, pair<const K,V>, Hash,GetMapKey> _ht;
	};
}